

#ifndef SEDITORBASE_H
#define SEDITORBASE_H

#include <wx/hashmap.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include "globals.h"
#include "settings.h"
#include "cbexception.h"

class wxMenu;
class SEditorBase;
class SEditorManager;
struct EditorBaseInternalData;

WX_DECLARE_HASH_MAP(int, SEditorBase*, wxIntegerHash, wxIntegerEqual, SSwitchToMap);



class SEditorBase : public wxPanel

{
    DECLARE_EVENT_TABLE()
    public:
        SEditorBase(wxWindow* parent, const wxString& filename);
        virtual ~SEditorBase();


        SEditorBase(const SEditorBase& rhs) { cbThrow(_T("Can't call SEditorBase's copy ctor!!!")); }


        virtual void operator=(const SEditorBase& rhs){ cbThrow(_T("Can't assign an SEditorBase* !!!")); }


        virtual const wxString& GetFilename() const { return m_Filename; }


        virtual void SetFilename(const wxString& filename){ m_Filename = filename; }


        virtual const wxString& GetShortName() const { return m_Shortname; }


        virtual bool GetModified() const { return false; }


        virtual void SetModified(bool  = true) {}


        virtual const wxString& GetTitle();


        virtual void SetTitle(const wxString& newTitle);


        virtual void Activate();


        virtual bool QueryClose(){ return true; }


        virtual bool Close();


        virtual bool Save() { return true; }


        virtual bool IsBuiltinEditor() const;


        virtual bool ThereAreOthers() const;


        virtual void DisplayContextMenu(const wxPoint& position, ModuleType type = mtUnknown);


        virtual bool VisibleToTree() const { return true; }


        virtual void GotoLine(int l, bool  = true){}


        virtual void ToggleBreakpoint(int  = -1, bool  = true){}


        virtual bool HasBreakpoint(int ) const { return false; }


        virtual void GotoNextBreakpoint(){}


        virtual void GotoPreviousBreakpoint(){}


        virtual void ToggleBookmark(int  = -1){}


        virtual bool HasBookmark(int ) const { return false; }


        virtual void GotoNextBookmark(){}


        virtual void GotoPreviousBookmark(){}


        virtual void SetDebugLine(int ){}


        virtual void SetErrorLine(int ){}


        virtual void Undo(){}


        virtual void Redo(){}


        virtual void Cut(){}


        virtual void Copy(){}


        virtual void Paste(){}


        virtual bool CanUndo() const { return false; }


        virtual bool CanRedo() const { return false; }


        virtual bool HasSelection() const { return false; }


        virtual bool CanPaste() const { return false; }


        virtual bool IsReadOnly() const { return false; }

        virtual void SearchGotoLine();
        virtual void SearchFind();
        virtual void SearchFindNext(bool next = true);
        virtual void OnSearchReplace();


    protected:


        virtual void InitFilename(const wxString& filename);


        virtual wxMenu* CreateContextSubMenu(int id);

        virtual void AddToContextMenu(wxMenu* , ModuleType , bool ) {}


        virtual wxString CreateUniqueFilename();


        virtual bool OnBeforeBuildContextMenu(const wxPoint& , ModuleType ){ return true; }


        virtual void OnAfterBuildContextMenu(ModuleType ){}

        virtual SEditorManager* GetEditorManager() const {return m_pEditorManager;}
        virtual wxWindow* GetEditorParent(){return m_pParent;}

        bool m_IsBuiltinEditor;
        wxString m_Shortname;
        wxString m_Filename;
        EditorBaseInternalData* m_pData;
    private:


        void OnContextMenuEntry(wxCommandEvent& event);
        void BasicAddToContextMenu(wxMenu* popup, ModuleType type);
        SSwitchToMap m_SwitchTo;
        wxString m_WinTitle;
        wxString lastWord;
        SEditorManager* m_pEditorManager;
        wxWindow* m_pParent;
};

#endif
